package com.tongle.frs.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tongle.frs.common.redis.RedisUtil;
import com.tongle.frs.service.BbsUserService;
import com.tongle.frs.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class LoginController {
	@Reference(version = "1.0.0")
	BbsUserService bbsUserService;
	@Reference(version = "1.0.0")
	RabbitService rabbitService;
	@Autowired
	RedisTemplate<String, String> redisTemp;

	@RequestMapping("/has")
	public String hasUser(){
		if (bbsUserService.hasUser("xxx")) {
			return "true";
		}
		return "false";
	}

	@RequestMapping("/mq")
	public String send() {
		rabbitService.send("你妹米的");
		return "OK";
	}

	@RequestMapping("/redis")
	public String redis() {
		RedisUtil redisUtil = new RedisUtil();
		redisUtil.setRedisTemplate(redisTemp);
		redisUtil.set("hice", "89757", null, TimeUnit.SECONDS);
		return "No";
	}
}
